COVID-19
Gráficos de análisis de Covid19
- Fecha actualización: 31/12/2019
- Casos acumulados por país
- Escala logaritmica de casos y casos acumulados por pais
- Argentina
fuente : https://www.ecdc.europa.eu/
df.dtypes
#collapse-hide
df.head(10)
#collapse-hide
source = df[df['max_cases'] >= 10000]
label = alt.selection_single(
encodings=['x'], # limit selection to x-axis value
on='mouseover', # select on mouseover events
nearest=True, # select data point nearest the cursor
empty='none' # empty selection includes no data points
)
alt.data_transformers.enable('default', max_rows=None)
# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
alt.X('dateRep:T'),
alt.Y('cum_cases:Q', scale=alt.Scale(type='log')),
alt.Color('pais:N')
)
alt.layer(
base, # base line chart
# add a rule mark to serve as a guide line
alt.Chart().mark_rule(color='#aaa').encode(
x='dateRep:T'
).transform_filter(label),
# add circle marks for selected time points, hide unselected points
base.mark_circle().encode(
opacity=alt.condition(label, alt.value(1), alt.value(0))
).add_selection(label),
# add white stroked text to provide a legible background for labels
base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=5).encode(
text='cum_cases:Q'
).transform_filter(label),
base.mark_text(align='left', dx=35, dy=-5, stroke='white', strokeWidth=5).encode(
text='pais:N'
).transform_filter(label),
# add text labels for stock prices
base.mark_text(align='left', dx=5, dy=-5).encode(
text='cum_cases:Q'
).transform_filter(label),
base.mark_text(align='left', dx=35, dy=-5).encode(
text='pais:N'
).transform_filter(label),
data=source
).properties(
width=700,
height=400
)
#collapse-hide
source = df[df['max_cases'] >= 10000]
label = alt.selection_single(
encodings=['x'], # limit selection to x-axis value
on='mouseover', # select on mouseover events
nearest=True, # select data point nearest the cursor
empty='none' # empty selection includes no data points
)
alt.data_transformers.enable('default', max_rows=None)
# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
alt.X('days:Q'),
alt.Y('cum_cases:Q', scale=alt.Scale(type='log')),
alt.Color('pais:N')
)
alt.layer(
base, # base line chart
# add a rule mark to serve as a guide line
alt.Chart().mark_rule(color='#aaa').encode(
x='days:Q'
).transform_filter(label),
# add circle marks for selected time points, hide unselected points
base.mark_circle().encode(
opacity=alt.condition(label, alt.value(1), alt.value(0))
).add_selection(label),
# add white stroked text to provide a legible background for labels
base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=2).encode(
text='cum_cases:Q'
).transform_filter(label),
# add text labels for stock prices
base.mark_text(align='left', dx=5, dy=-5).encode(
text='cum_cases:Q'
).transform_filter(label),
base.mark_text(align='left', dx=40, dy=-5).encode(
text='pais:N'
).transform_filter(label),
data=source
).properties(
width=700,
height=400
)
#collapse-hide
source = df[df['cases'] > 0]
source = source[source['max_cases'] >= 30000]
label = alt.selection_single(
encodings=['x'], # limit selection to x-axis value
on='mouseover', # select on mouseover events
nearest=True, # select data point nearest the cursor
empty='none' # empty selection includes no data points
)
alt.data_transformers.enable('default', max_rows=None)
# define our base line chart of stock prices
base = alt.Chart().mark_line(point=True).encode(
alt.X('cum_cases:Q', axis=alt.Axis(grid=False), scale=alt.Scale(type='log')),
alt.Y('cases:Q', axis=alt.Axis(grid=False), scale=alt.Scale(type='log')),
alt.Color('pais:N')
)
alt.layer(
base, # base line chart
# add a rule mark to serve as a guide line
alt.Chart().mark_rule(color='#aaa').encode(
x='cum_cases:Q'
).transform_filter(label),
# add circle marks for selected time points, hide unselected points
base.mark_circle().encode(
opacity=alt.condition(label, alt.value(1), alt.value(0))
).add_selection(label),
# add white stroked text to provide a legible background for labels
base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=2).encode(
text='cum_cases:Q'
).transform_filter(label),
# add text labels for stock prices
base.mark_text(align='left', dx=5, dy=-5).encode(
text='cum_cases:Q'
).transform_filter(label),
base.mark_text(align='left', dx=40, dy=-5).encode(
text='pais:N'
).transform_filter(label),
data=source
).properties(
width=700,
height=400
)
#collapse-hide
source = df#.where(df['max_cases'] >= 1000)
label = alt.selection_single(
encodings=['x'], # limit selection to x-axis value
on='mouseover', # select on mouseover events
nearest=True, # select data point nearest the cursor
empty='none' # empty selection includes no data points
)
alt.data_transformers.enable('default', max_rows=None)
# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
alt.X('days:Q'),
alt.Y('cum_deaths:Q'),
alt.Color('pais:N')
)
alt.layer(
base, # base line chart
# add a rule mark to serve as a guide line
alt.Chart().mark_rule(color='#aaa').encode(
x='days:Q'
).transform_filter(label),
# add circle marks for selected time points, hide unselected points
base.mark_circle().encode(
opacity=alt.condition(label, alt.value(1), alt.value(0))
).add_selection(label),
# add white stroked text to provide a legible background for labels
base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=2).encode(
text='cum_deaths:Q'
).transform_filter(label),
base.mark_text(align='left', dx=37, dy=-5, stroke='white', strokeWidth=2).encode(
text='pais:N'
).transform_filter(label),
# add text labels for stock prices
base.mark_text(align='left', dx=5, dy=-5).encode(
text='cum_deaths:Q'
).transform_filter(label),
base.mark_text(align='left', dx=37, dy=-5).encode(
text='pais:N'
).transform_filter(label),
data=source
).properties(
width=700,
height=400
)
#collapse-hide
source = df#.where(df['max_cases'] >= 1000)
label = alt.selection_single(
encodings=['x'], # limit selection to x-axis value
on='mouseover', # select on mouseover events
nearest=True, # select data point nearest the cursor
empty='none' # empty selection includes no data points
)
alt.data_transformers.enable('default', max_rows=None)
# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
alt.X('dateRep:T'),
alt.Y('cum_deaths:Q'),
alt.Color('pais:N')
)
alt.layer(
base, # base line chart
# add a rule mark to serve as a guide line
alt.Chart().mark_rule(color='#aaa').encode(
x='dateRep:T'
).transform_filter(label),
# add circle marks for selected time points, hide unselected points
base.mark_circle().encode(
opacity=alt.condition(label, alt.value(1), alt.value(0))
).add_selection(label),
# add white stroked text to provide a legible background for labels
base.mark_text(align='right', dx=5, dy=-5, stroke='white', strokeWidth=5).encode(
text='cum_deaths:Q'
).transform_filter(label),
base.mark_text(align='right', dx=5, dy=-15, stroke='white', strokeWidth=5).encode(
text='pais:N'
).transform_filter(label),
# add text labels for stock prices
base.mark_text(align='right', dx=5, dy=-5).encode(
text='cum_deaths:Q'
).transform_filter(label),
base.mark_text(align='right', dx=5, dy=-15).encode(
text='pais:N'
).transform_filter(label),
data=source
).properties(
width=700,
height=400
).interactive()
#collapse-hide
date = data['dateRep'].max()
source = df.where(df['dateRep'] >= date)
source = source.where(source['max_cases'] >= 1000)
alt.Chart(source).mark_circle(size=100).encode(
alt.X('cum_cases:Q'),
alt.Y('cum_deaths:Q'),
color='pais',
tooltip=['pais:N', 'cum_deaths:Q', 'cum_cases:Q']
).properties(
width=700,
height=400
).interactive()
#collapse-hide
source = df.where(df['pais'] == 'Argentina')
label = alt.selection_single(
encodings=['x'], # limit selection to x-axis value
on='mouseover', # select on mouseover events
nearest=True, # select data point nearest the cursor
empty='none' # empty selection includes no data points
)
# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
alt.X('days:Q'),
alt.Y('cum_cases:Q', scale=alt.Scale(type='log')),
alt.Color('pais:N')
)
overlay = pd.DataFrame({'cuarentena': [13]})
vline = alt.Chart(overlay).mark_rule(color='red', strokeWidth=1).encode(x='cuarentena:Q')
alt.layer(
base, vline,# base line chart
# add a rule mark to serve as a guide line
alt.Chart().mark_rule(color='#aaa').encode(
x='days:Q'
).transform_filter(label),
# add circle marks for selected time points, hide unselected points
base.mark_circle().encode(
opacity=alt.condition(label, alt.value(1), alt.value(0))
).add_selection(label),
# add white stroked text to provide a legible background for labels
base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=5).encode(
text='cum_cases:Q'
).transform_filter(label),
# add text labels for stock prices
base.mark_text(align='left', dx=5, dy=-5).encode(
text='cum_cases:Q'
).transform_filter(label),
data=source
).properties(
width=700,
height=400 )
# La línea roja marca el inicio de la cuarentena
#collapse-hide
source = df.query('pais in ["Argentina", "Chile", "Brazil", "Spain"]')
label = alt.selection_single(
encodings=['x'], # limit selection to x-axis value
on='mouseover', # select on mouseover events
nearest=True, # select data point nearest the cursor
empty='none' # empty selection includes no data points
)
# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
alt.X('days:Q'),
alt.Y('cum_cases:Q', scale=alt.Scale(type='log')),
alt.Color('pais:N')
)
overlay = pd.DataFrame({'cuarentena': [13]})
vline = alt.Chart(overlay).mark_rule(color='red', strokeWidth=1).encode(x='cuarentena:Q')
alt.layer(
base, vline,# base line chart
# add a rule mark to serve as a guide line
alt.Chart().mark_rule(color='#aaa').encode(
x='days:Q'
).transform_filter(label),
# add circle marks for selected time points, hide unselected points
base.mark_circle().encode(
opacity=alt.condition(label, alt.value(1), alt.value(0))
).add_selection(label),
# add white stroked text to provide a legible background for labels
base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=5).encode(
text='cum_cases:Q'
).transform_filter(label),
# add text labels for stock prices
base.mark_text(align='left', dx=5, dy=-5).encode(
text='cum_cases:Q'
).transform_filter(label),
data=source
).properties(
width=700,
height=400 )
# La línea roja marca el inicio de la cuarentena
#collapse-hide
source = df.where(df['pais'] == 'Argentina')
label = alt.selection_single(
encodings=['x'], # limit selection to x-axis value
on='mouseover', # select on mouseover events
nearest=True, # select data point nearest the cursor
empty='none' # empty selection includes no data points
)
# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
alt.X('days:Q'),
alt.Y('cum_deaths:Q'),
alt.Color('pais:N')
)
overlay = pd.DataFrame({'cuarentena': [13]})
vline = alt.Chart(overlay).mark_rule(color='red', strokeWidth=1).encode(x='cuarentena:Q')
alt.layer(
base, vline, # base line chart
# add a rule mark to serve as a guide line
alt.Chart().mark_rule(color='#aaa').encode(
x='days:Q'
).transform_filter(label),
# add circle marks for selected time points, hide unselected points
base.mark_circle().encode(
opacity=alt.condition(label, alt.value(1), alt.value(0))
).add_selection(label),
# add white stroked text to provide a legible background for labels
base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=2).encode(
text='cum_deaths:Q'
).transform_filter(label),
# add text labels for stock prices
base.mark_text(align='left', dx=5, dy=-5).encode(
text='cum_deaths:Q'
).transform_filter(label),
data=source
).properties(
width=700,
height=400
)
# La línea roja marca el inicio de la cuarentena
#collapse-hide
source = df.where(df['pais'] == 'Argentina')
label = alt.selection_single(
encodings=['x'], # limit selection to x-axis value
on='mouseover', # select on mouseover events
nearest=True, # select data point nearest the cursor
empty='none' # empty selection includes no data points
)
# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
alt.X('dateRep:T'),
alt.Y('cases:Q'),
alt.Color('pais:N'),
tooltip=['pais:N', 'dateRep:T', 'cum_cases:Q']
)
overlay = pd.DataFrame({'cuarentena': ['2020-03-17']})
vline = alt.Chart(overlay).mark_rule(color='red', strokeWidth=1).encode(x='cuarentena:T')
alt.layer(
base, vline, # base line chart
# add a rule mark to serve as a guide line
alt.Chart().mark_rule(color='#aaa').encode(
x='dateRep:T'
).transform_filter(label),
# add circle marks for selected time points, hide unselected points
base.mark_circle().encode(
opacity=alt.condition(label, alt.value(1), alt.value(0))
).add_selection(label),
# add white stroked text to provide a legible background for labels
base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=2).encode(
text='cases:Q'
).transform_filter(label),
# add text labels for stock prices
base.mark_text(align='left', dx=5, dy=-5).encode(
text='cases:Q'
).transform_filter(label),
data=source
).properties(
width=700,
height=400
)
# La línea roja marca el inicio de la cuarentena
#collapse-hide
source = df[df['max_cases'] >= 50000]
source = source[source['cases'] > 0]
label = alt.selection_single(
encodings=['x'], # limit selection to x-axis value
on='mouseover', # select on mouseover events
nearest=True, # select data point nearest the cursor
empty='none' # empty selection includes no data points
)
alt.data_transformers.enable('default', max_rows=None)
# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
alt.X('days:Q'),
alt.Y('cases:Q', scale=alt.Scale(type='log')),
alt.Color('pais:N')
)
alt.layer(
base, # base line chart
# add a rule mark to serve as a guide line
alt.Chart().mark_rule(color='#aaa').encode(
x='days:Q'
).transform_filter(label),
# add circle marks for selected time points, hide unselected points
base.mark_circle().encode(
opacity=alt.condition(label, alt.value(1), alt.value(0))
).add_selection(label),
# add white stroked text to provide a legible background for labels
base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=2).encode(
text='cases:Q'
).transform_filter(label),
base.mark_text(align='left', dx=37, dy=-5, stroke='white', strokeWidth=2).encode(
text='pais:N'
).transform_filter(label),
# add text labels for stock prices
base.mark_text(align='left', dx=5, dy=-5).encode(
text='cases:Q'
).transform_filter(label),
base.mark_text(align='left', dx=37, dy=-5).encode(
text='pais:N'
).transform_filter(label),
data=source
).properties(
width=700,
height=400
)
#collapse-hide
source = df[df['max_cases'] >= 50000]
source = source[source['deaths'] > 0]
label = alt.selection_single(
encodings=['x'], # limit selection to x-axis value
on='mouseover', # select on mouseover events
nearest=True, # select data point nearest the cursor
empty='none' # empty selection includes no data points
)
alt.data_transformers.enable('default', max_rows=None)
# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
alt.X('days:Q'),
alt.Y('deaths:Q', scale=alt.Scale(type='log')),
alt.Color('pais:N')
)
alt.layer(
base, # base line chart
# add a rule mark to serve as a guide line
alt.Chart().mark_rule(color='#aaa').encode(
x='days:Q'
).transform_filter(label),
# add circle marks for selected time points, hide unselected points
base.mark_circle().encode(
opacity=alt.condition(label, alt.value(1), alt.value(0))
).add_selection(label),
# add white stroked text to provide a legible background for labels
base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=2).encode(
text='deaths:Q'
).transform_filter(label),
base.mark_text(align='left', dx=37, dy=-5, stroke='white', strokeWidth=2).encode(
text='pais:N'
).transform_filter(label),
# add text labels for stock prices
base.mark_text(align='left', dx=5, dy=-5).encode(
text='deaths:Q'
).transform_filter(label),
base.mark_text(align='left', dx=37, dy=-5).encode(
text='pais:N'
).transform_filter(label),
data=source
).properties(
width=700,
height=400
)